

export const tableBaseMixin = {
  data() {
    return {
      page: {
        current: 1,
        size: 10,
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      selectionData: [],
      tableData: [],
      listLoading: false,
      searchQuery: {},
      pageQuery: {
        current: 1,
        size: 10
      },
      downLoadUrl: {
        downLoadUrl: '',
        excelName: ''
      },
    }
  },
  created() {

  },
  methods: {
    async doExportRequest(exportParams) {
      const response = await this.exportRequest(exportParams.url, exportParams.method || 'get', exportParams.params)
      const {
        status,
        data,
        statusText
      } = response
      if (status === 200) {
        this.downloadFile(data, exportParams.fileName)
      } else {
        this.$message.error(statusText)
      }
    },
    currentChange(val) {
      this.page.current = val
      this.page.page = val;
      this.page.currentPage = val;
      this.getList();
    },
    sizeChange(val) {
      this.page.current = 1;
      this.page.size = val;
      this.page.limit = val;
      this.page.pageSize = val;
      this.getList();
    },
    refreshChange () {
      this.getList();
    },
    refreshData () {
      this.getList();
    },
    //  搜索栏搜索
    async searchChange(form, done) {
      this.page.current = 1
      this.page.currentPage = 1
      form && (this.searchQuery = form)
      done && done()
      await this.getList();
    },
    selectionChange(val) {
      this.selectionData = val;
    },
    handlePrint() {
      this.$message.warning('功能暂未开放，敬请期待！')
    },
  }
}
